package com.qf.day06;

public class Animar {
    private String name;

    private String type;

    private String sex;

    private int age;

    private int hungry=10; // 动物的饥饿值

    public Animar() {
    }

    public Animar(String name, String type, String sex, int age) {
        this.name = name;
        this.type = type;
        this.sex = sex;
        this.age = age;
    }

    // 实例方法一般写在构造方法后面

    public void eat(){
        System.out.println(name+"在吃饭");
        this.hungry = this.hungry - 1;
    }

    public void sleep(){
        System.out.println(name+"在睡觉");
    }



    //一般把setter和getter放到类的最后
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getHungry() {
        return hungry;
    }

    public void setHungry(int hungry) {
        this.hungry = hungry;
    }

    @Override
    public String toString() {
        return "Animal{" +
                "name='" + name + '\'' +
                ", type='" + type + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                ", hungry=" + hungry +
                '}';
    }
}
